package com.os.osframe.scaffold.web;

import com.os.osframe.scaffold.domain.AutoConfigModule;
import com.os.osframe.scaffold.service.IConfigModuleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by wangchun on 16/7/4.
 */
@Controller
public class AutoIndexController {

    @Resource
    IConfigModuleService configModuleService;
    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView defaultIndex() throws Exception {
        ModelAndView modelView = new ModelAndView();
        modelView.setViewName("redirect:/index.html");//默认直接跳转到首页
        return modelView;
    }
    @RequestMapping("/index")
    public String index(HttpServletRequest request)throws Exception {
        return "config/index";//路径获取为通用
    }
    @RequestMapping("/nav")
    public String nav(HttpServletRequest request)throws Exception {
        List<AutoConfigModule> moduleList=configModuleService.getModuleList();
        request.setAttribute("moduleList", moduleList);
        return "config/nav";
    }
}
